package com.example.f8399.testdemo.activity;

import android.databinding.DataBindingUtil;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.TransitionDrawable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import com.example.f8399.testdemo.BaseActivity;
import com.example.f8399.testdemo.R;
import com.example.f8399.testdemo.databinding.ActivityOpenLightBinding;

public class OpenLightActivity extends BaseActivity {

    ActivityOpenLightBinding mBinding;
    boolean isOpen;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       mBinding = DataBindingUtil. setContentView(this,R.layout.activity_open_light);
       mBinding.setAc(this);

    }


    public void go(View view) {

        if (isOpen) {
            isOpen = false;
            mBinding.iv.setImageResource(R.drawable.trans_on);
            TransitionDrawable drawable = (TransitionDrawable) mBinding.iv.getDrawable();
            drawable.startTransition(3000);
        }else {
            isOpen = true;
            mBinding.iv.setImageResource(R.drawable.trans_off);
            TransitionDrawable drawable = (TransitionDrawable) mBinding.iv.getDrawable();
            drawable.startTransition(3000);
        }
    }
}
